﻿Imports ajayumi.develop.win32.GameEditor.Base
Imports ajayumi.develop.VBasic.Core.Win.WinAPI

Public Class AlienBreed2Assault
    Inherits GameBase

    Public Sub New(ByVal pName As String)
        Me.New(pName, pName)
    End Sub

    Public Sub New(ByVal name As String, ByVal pName As String)
        MyBase.New(name, pName)
    End Sub

    Public Overrides Function ToString() As String
        Return "AlienBreed2Assault"
    End Function


    ''' <summary>
    ''' 修改突击步枪弹药
    ''' </summary>
    ''' <param name="value">待修改的突击步枪弹药值</param>
    ''' <remarks></remarks>
    Public Sub ChangeAmmo1(ByVal value As Integer)
        Try
            If Me.m_Processes.Length <= 0 Then
                Throw New Exception(String.Format("{0} 程序未运行", Me.ToString()))
                Exit Sub
            End If

            For Each item As Process In Me.m_Processes
                Dim _ProcessID As Integer = item.Id

                '获得进程
                Dim _hProc As Integer = Kernal32Dll.OpenProcess(PROCESS_ALL_ACCESS, False, _ProcessID)

                If _hProc <= 0 Then
                    Throw New Exception(String.Format("{0} 程序未运行", Me.ToString()))
                    Exit Sub
                End If

                Console.WriteLine("已获得 {0} 程序句柄", Me.ToString())

                Dim _MemoryAddress As Integer = &H11D4204 '读取内存地址    
                Dim _Data As Integer = 0
                Dim _Reslut As Integer = 0
                Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
                _MemoryAddress = _Data + &H334
                'Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
                '_MemoryAddress = _Data + &H22C
                'Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
                '_MemoryAddress = _Data + &H180

                _Data = value  '写入的新值   
                Kernal32Dll.WriteProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
                '写内存
                Kernal32Dll.CloseHandle(_hProc)
            Next
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    '''' <summary>
    '''' 修改香精值
    '''' </summary>
    '''' <param name="value">待修改的香精值</param>
    '''' <remarks></remarks>
    'Public Sub ChangeEssence(ByVal value As Integer)
    '    Try
    '        If Me.m_Processes.Length <= 0 Then
    '            Throw New Exception(String.Format("{0} 程序未运行", Me.ToString()))
    '            Exit Sub
    '        End If

    '        For Each item As Process In Me.m_Processes
    '            Dim _ProcessID As Integer = item.Id

    '            '获得进程
    '            Dim _hProc As Integer = Kernal32Dll.OpenProcess(PROCESS_ALL_ACCESS, False, _ProcessID)

    '            If _hProc <= 0 Then
    '                Throw New Exception(String.Format("{0} 程序未运行", Me.ToString()))
    '                Exit Sub
    '            End If

    '            Console.WriteLine("已获得 {0} 程序句柄", Me.ToString())

    '            Dim _MemoryAddress As Integer = &H54398C '读取内存地址    
    '            Dim _Data As Integer = 0
    '            Dim _Reslut As Integer = 0
    '            Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            _MemoryAddress = _Data + &H1E4
    '            Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            _MemoryAddress = _Data + &H22C
    '            Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            _MemoryAddress = _Data + &H184

    '            _Data = value  '写入的新值   
    '            '写内存
    '            Kernal32Dll.WriteProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            Kernal32Dll.CloseHandle(_hProc)
    '        Next
    '    Catch ex As Exception
    '        Throw ex
    '    End Try
    'End Sub

    'Public Sub UnlimitedMode()
    '    Try
    '        If Me.m_Processes.Length <= 0 Then
    '            Throw New Exception(String.Format("{0} 程序未运行", Me.ToString()))
    '            Exit Sub
    '        End If

    '        For Each item As Process In Me.m_Processes
    '            Dim _ProcessID As Integer = item.Id

    '            '获得进程
    '            Dim _hProc As Integer = Kernal32Dll.OpenProcess(PROCESS_ALL_ACCESS, False, _ProcessID)

    '            If _hProc <= 0 Then
    '                Throw New Exception(String.Format("{0} 程序未运行", Me.ToString()))
    '                Exit Sub
    '            End If

    '            Console.WriteLine("已获得 {0} 程序句柄", Me.ToString())

    '            Dim _MemoryAddress As Integer = &H483C8B '读取内存地址    
    '            Dim _Data As Integer = 0
    '            Dim _Reslut As Integer = 0
    '            Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            _MemoryAddress = _Data + &H1E4
    '            Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            _MemoryAddress = _Data + &H22C
    '            Kernal32Dll.ReadProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)
    '            _MemoryAddress = _Data + &H184

    '            '_Data = value  '写入的新值   
    '            '写内存
    '            Kernal32Dll.WriteProcessMemory(_hProc, _MemoryAddress, _Data, 4, _Reslut)

    '            Kernal32Dll.CloseHandle(_hProc)
    '        Next
    '    Catch ex As Exception
    '        Throw ex
    '    End Try
    'End Sub

    Public Overrides Sub Modify()

    End Sub
End Class
